package com.lnsf.bookstore.web.category.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lnsf.bookstore.common.util.StringUtil;
import com.lnsf.bookstore.web.category.vo.ApiCategory;
import com.lnsf.bookstore.web.category.dao.ApiCategoryMapper;
import com.lnsf.bookstore.web.category.service.ApiCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ApiCategoryServiceImpl implements ApiCategoryService {

    @Autowired
    private ApiCategoryMapper apiCategoryMapper;

    public ApiCategory queryObject(Integer id){
        return apiCategoryMapper.queryObject(id);
    }


    public PageInfo<ApiCategory> queryList(Map<String, Object> map){
        if(StringUtil.getStringVal(map.get("page"))!= "" && StringUtil.getStringVal(map.get("limit"))!= "" ){
            PageHelper.startPage(Integer.parseInt(map.get("page").toString()),Integer.parseInt(map.get("limit").toString()));
        }

        return new PageInfo<ApiCategory>(apiCategoryMapper.queryList(map)) ;
    }


}
